import axios from 'axios'
// import {useUserStore} from '@/stores/user'
const API = {
	"baseURL":"http://api.iheater.pdev.top",
	"mock": "http://127.0.0.1:4523/m1/4211326-0-default"
}
export const BASE_URL = API['mock']

export const OK = 200
export const FAILED = 0

const instance = axios.create({
    baseURL: BASE_URL,
    timeout: 1000,
});
instance.interceptors.request.use(config=>{
    // const userStore =useUserStore()
    // const token = userStore.token
    // if(token){
    //     config.headers.Authorization = userStore.token
    // }
    return config
},e=>Promise.reject(e))

instance.interceptors.response.use(
    (res) => {
        // 对响应数据
        if (res.data.code == 200) {
            return res.data;
        }
        return Promise.reject(res.data);
        // return res;
    },
    (error) => {
        // 对响应错误
        return Promise.reject(error);
    });

export default instance